package file;

import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.util.Arrays;

public class ListFilesDemo2 {
    public static void main(String[] args) {
        File file=new File("d:\\loo");

        if(file.exists()){
            File[] subs=file.listFiles(filename
                    ->filename.getName().endsWith(".txt"));
            for (File f:subs
            ) {
                System.out.println(f.getName());
            }
        }


        String[] sub2=file.list();
        System.out.println(Arrays.toString(sub2));
    }
}
